#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int N = 5e6 + 10;
vector<int> edges[N];
queue<int> q;
int n, m;
int in[N], out[N];
int f[N];
const int MOD = 80112002;
int main()
{
	cin >> n >> m;
	while (m--)
	{
		int x = 0, y = 0;
		cin >> x >> y;
		edges[x].push_back(y);
		in[y]++;
		out[x]++;
	}
	for (int i = 1;i <= n;i++)
	{
		if (in[i] == 0)
		{
			f[i] = 1;
			q.push(i);
		}
	}
	while (q. size())
	{
		int x = q.front();
		q.pop();

		for (auto e : edges[x])
		{
			in[e]--;
			//注意千万不要写out[x]--，不然到后面根本就没办法判断出口
			f[e] = (f[e] + f[x]) % MOD;
			if (in[e] == 0) q.push(e);
		}
	}
	int ret = 0;
	for (int i = 1;i <= n;i++)
	{
		if (out[i] == 0)
		{
			ret = (ret + f[i]) % MOD;
		}
	}
	cout << ret << endl;
	return 0;
}